<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="zh-cn">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="renderer" content="webkit">
		<title>罗米后台管理-后台管理</title>
		<link rel="stylesheet" href="/Public/css/pintuer.css">
		<link rel="stylesheet" href="/Public/css/admin.css">
		<script src="/Public/js/jquery.js"></script>
		<script src="/Public/js/pintuer.js"></script>
		<script src="/Public/js/respond.js"></script>
		<script src="/Public/js/admin.js"></script>
		<link type="image/x-icon" href="/favicon.ico" rel="shortcut icon" />
		<link href="/favicon.ico" rel="bookmark icon" />
		<base target="iframe" />
	</head>

<body>
	<form method="post">
		<div class="panel admin-panel">
			<div class="panel-head"><strong>内容列表</strong>
			</div>
			<div class="padding border-bottom">
				<input type="button" class="button button-small checkall" name="checkall" checkfor="id" value="全选" onclick="allCheck();" />
				<input type="button" class="button button-small checkall" name="checkall" checkfor="id" value="全不选" onclick="allnoCheck();" />
				<input type="button" class="button button-small border-green" value="添加文章" onclick="jumpUrl();" />
				<input type="button" class="button button-small border-yellow" value="批量删除" onclick="removeAll();" />
				<input type="button" class="button button-small border-blue" value="回收站" />
			</div>
			<table class="table table-hover">
				<tr>
					<th width="45">选择</th>
					<th width="*">标题</th>
					<th width="200">时间</th>
					<th width="100">操作</th>
				</tr>
				<?php if(is_array($list)): foreach($list as $k=>$vo): ?><tr>
						<td>
							<input type="checkbox" name="aid" value="<?php echo ($vo["aid"]); ?>" class="aid" />
						</td>
						<td><?php echo ($vo["title"]); ?></td>
						<td><?php echo ($vo["addtime"]); ?></td>
						<td>
							<a class="button border-blue button-little" href="#">修改</a>
							<a class="button border-yellow button-little" href="javascript:;" onclick="delData(this);return false;" cid="<?php echo ($vo["aid"]); ?>">删除</a>
						</td>
					</tr><?php endforeach; endif; ?>
			</table>
			<div class="panel-foot text-center">
				<!--<ul class="pagination">
					<li><a href="#">上一页</a>
					</li>
				</ul>
				<ul class="pagination pagination-group">
					<li><a href="#">1</a>
					</li>
					<li class="active"><a href="#">2</a>
					</li>
					<li><a href="#">3</a>
					</li>
					<li><a href="#">4</a>
					</li>
					<li><a href="#">5</a>
					</li>
				</ul>
				<ul class="pagination">
					<li><a href="#">下一页</a>
					</li>
				</ul>-->
				<?php echo ($page); ?>
			</div>
		</div>
	</form>

	<script type="text/javascript">
		var APP = "/index.php";

		function delData(obj) {
				var cid = $(obj).attr('cid');
				if (confirm("你确定要删除吗？")) {
					$.post(APP + '/Lmkj/Content/ajaxDelArticle', {
						'id': cid
					}, function(data) {
						if (data) {
							window.location.reload();
						} else {
							alert("未知错误");
						}
					}, 'json');
				}
			}
		/**
		 *跳转函数
		 */
		function jumpUrl() {
				window.location.href = APP + "/Lmkj/Content/showAddArticle";
			}
		/**
		 * 删除全部
		 */

		function removeAll() {
			// 判断是否至少选择一项 
			var checkedNum = $(".aid:checked").length; 
			if(checkedNum == 0){
				alert("您至少选择一项");
				return false;
			}
			
			// 批量选择 
			if(confirm("确定要删除所选项目？")) { 
				var checkedList = new Array(); 
				$(".aid:checked").each(function() { 
					checkedList.push($(this).val()); 
				})
			}
			
			//异步删除
			$.post(APP+"/Lmkj/Content/ajaxDelAll",{"ids":checkedList},function(data){
				if(data){
					$(".aid").removeAttr("checked"); 
					window.location.reload();
				}
			},'json');
		}
			
		/**
		*全选
		*/
		function allCheck() {
			$(".aid").prop("checked", true);  
		}
		
		/**
		 *全不选 
		 */
		function allnoCheck(){
			$(".aid").removeAttr("checked"); 
		}
		
	</script>
</body>

</html>